package com.eaoa.query.pub;

import java.util.List;

import com.eaoa.base.EABaseQuery;
import com.eaoa.vo.pub.PubMessage;

public class PubMessageQuery extends EABaseQuery {

	public PubMessageQuery() {
		super(PubMessage.class);
	}

	public void setReceiver(Long val) {
		setEQCondition("receiver", val);
	}

	public void setSubject(String val) {
		this.setLIKECondition("subject", val);
	}
	
	public void setSender(Long val) {
		setEQCondition("sender", val);
	}
	
	public void setSessionid(Long val) {
		setEQCondition("sessionid", val);
	}

	public void setSendername(String sendername) {
		this.setLIKECondition("sendername", sendername);
	}

	public void setReceivername(String receivername) {
		this.setLIKECondition("receivername", receivername);
	}

	public void setSenderdate(String fromdate, String todate) {
		buildDateCondition("senderdate", fromdate, todate);
	}

	public void setKeyword(String val) {
		setLIKECondition("keyword", val);
	}

	public static PubMessage loadByNo(Long messageno) {
		if (messageno == null)
			return null;
		PubMessageQuery query = new PubMessageQuery();
		query.setMessageno(messageno);
		query.execute();
		if (query.getResults().size() != 1)
			return null;
		return (PubMessage) query.getResults().get(0);
	}
	
	@SuppressWarnings("unchecked")
	public static List<PubMessage> loadBySessionid(Long val) {
		if (val == null)
			return null;
		PubMessageQuery query = new PubMessageQuery();
		query.setSessionid(val);
		query.execute();
		return query.getResults();
	}

	public void setMessageno(Long val) {
		setEQCondition("messageno", val);
	}

	public void setStatus(String val) {
		setEQCondition("status", val);
	}
	
	public void setStatus(String[] val) {
		setINCondition("status", val);
	}
	
	public void setMessagetype(String val) {
		setEQCondition("messagetype", val);
	}

	public void setIslock(String val) {
		setEQCondition("islock", val);
	}

}
